<script type="text/javascript">   
    function LTrim(value) {
        var re = /\s*((\S+\s*)*)/;
        return value.replace(re, "$1");
    }

    function RTrim(value) {
        var re = /((\s*\S+)*)\s*/;
        return value.replace(re, "$1");
    }

    function trim(value) {
        return LTrim(RTrim(value));
    }
    
    function user_validate() {
        var fullname       = trim(document.getElementById('fullname').value);
        var birthday    = trim(document.getElementById('birthday').value);
        var countError  = 0;
        
        if(fullname === '')
        {
            document.getElementById("errorFullname").innerHTML="<i><font color='red' > Trường tên không được để trống!.</font></i>";
            countError++;
        }
        else if((fullname.length > 50) || (fullname.length < 5))
        {
            document.getElementById("errorFullname").innerHTML="<i><font color='red' > Trường tên phải có độ dài từ 5-50 kí tự!</font></i>";
            countError++;
        }
        else
        {
            var reg = /^[a-zA-ZÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠàáâãèéêìíòóôõùúăđĩũơƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂưăạảấầẩẫậắằẳẵặẹẻẽếềểỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪễệỉịọỏốồổỗộớờởỡợụủứừỬỮỰỲỴÝỶỸửữựỳỵỷỹ ]+$/;
            if(reg.test(fullname) === false)
            {
                document.getElementById("errorFullname").innerHTML= "<i><font color='red' > Tên đầy đủ gồm các kí tự chữ cái, không chứa chữ số!.</font></i>";
                countError++;
            }
            else
            {
                document.getElementById("errorFullname").innerHTML = "";
            }
        }
        if(countError > 0)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    
</script>
<script type="text/javascript">

    	$(document).ready(function(){		
    		getDatePicker('expiry_day');	
    	});
    	
    	// datepicker
    	function getDatePicker(_id) {	
    	$("#"+_id).datepicker({
    		 showOn:'button',
    		 dateFormat:"yy-mm-dd",
    		 buttonImage:'<?php echo $this->baseUrl(); ?>'+'/public/templates/admin/js/calendar/images/calendar.gif',
    		 buttonImageOnly:true,
    		 yearRange: '2000:2020',
    		 changeMonth:true,
    		 changeYear:true,
    		 showMonthAfterYear: true
    		 //minDate:0
    	   });
    	 }
</script>
<div class="widget">
    <h3 style="text-align: left">Thông tin tài khoản</h3>
    
    <div class="profile_content">
        <form action="" method="post" onsubmit="return user_validate();" enctype="multipart/form-data">
            <table class="profile_table" border="1" > 
                <tr>
                <td>Thông tin cá nhân</td>
            </tr>
            <tr>
                <td class="label">Email</td>
                <td class="label2" style="font-weight:bold;"><?php echo $this->email ?></td>
                <td><span class="msg" id="errname"></span></td>
            </tr> 
            <tr>
                <td class="label">Tên đầy đủ</td>
                <td class="label2"><input class="input_rg" type="text" size="30" name="fullname" value="<?php echo $this->fullname; ?>" id="name" /></td>
                <td ><span class="msg" id="errFullname"><?php echo $this->errFullname?></span></td>
            </tr>        
            <tr>
                <td>Ngày sinh</td>
                <td><input  class="input_rg" type="text" size="30" name="birthday" id="expiry_day"  value="<?php echo $this->birthday; ?>"/></td>
                <td><span class="msg" id="errBirthday"><?php echo $this->errbirthday?></span></td>
            </tr>
             <tr>
                <td>Giới tính</td>
                <?php if(($this->gender)==1): ?>
                <td>
                    <select  name="gender" id="gender">
				        <option value="1" selected="selected">Nam</option>
    				    <option value="0">Nữ</option>
				    </select>
                </td>
                <?php else: ?>
                <td>
                    <select  name="gender">
				        <option value="1">Nam</option>
    				    <option value="0" selected="selected">Nữ</option>
				    </select>
                </td>
                <?php endif ?>
            </tr> 
            <tr>
                <td class="label">Ảnh đại diện</td>
                <td ><input type="file" name="file" /></td>
                
            </tr>
               
                <tr>
                    <td class="label">&nbsp;</td>
                    <td colspan="2" style="width: 300px">
                        <input class="button" style="float: left;" type="submit" name="submit" value="Cập nhật"/>
                        
                    </td>
                </tr>
                <tr>
                    <td class="label" colspan="3"><span class="success"><?php echo $this->success ?></span></td>
                    
                </tr>
            </table>
            <div class="avatar_table">
            <table border="0"  cellspacing="15" >
                <tr>
                <td align="center" style="font-weight:bold"> 
                    Ảnh đại diện
                </td>
                </tr>
                  <tr>
                  <td>
                    <?php if($this->avatar!=''): ?>
                            <img class="img_avatar" width="150px" height="150px" src="<?php echo $this->baseUrl('/public/img/user/'.$this->avatar) ?>"/>
                        <?php else:?>                       
                            <img class="img_avatar" width="150px" height="150px" src="<?php echo $this->baseUrl('/public/img/user/default.jpg') ?>"/>
                        <?php endif;  ?>
                        
                    </td>
                  </tr> 
                  <tr  >
                  <td align="center" style="font-weight:bold;font-style:italic;" >
                    <a href="<?php echo $this->baseUrl()?>/user/changepass/Id/ "><i>Thay đổi mật khẩu</i></a>
                  </td>
                  </tr>
            </table>
            </div>
        </form>
    </div>
</div>